package org.sn.jdish.designmode.singleton;

/**
 * 单例（双重加锁懒汉式）
 * 
 * @author snzigod@hotmail.com
 *
 */
public class LazySingleton {

	private LazySingleton() {
	}

	private volatile static LazySingleton singleton = null;

	public static LazySingleton getInstance() {
		if (singleton == null) {
			synchronized (LazySingleton.class) {
				if (singleton == null) {
					singleton = new LazySingleton();
				}
			}
		}
		return singleton;
	}
	
	public void singleton() {
		System.out.println("this is a singleton method!");
	}

}
